package com.taxi.controller;

import com.taxi.dto.PriceRule;
import com.taxi.request.PriceRuleIsNewRequest;
import com.taxi.result.Result;
import com.taxi.service.PriceRuleService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: aniu
 * @Date: 2023/10/4
 * @ClassName: PriceRultController
 * @Description: Write class functionality and purpose here.
 * @Version: 1.0
 */
@RestController
@RequestMapping("/price-rule")
public class PriceRuleController {
    @Autowired
    private PriceRuleService priceRuleService;

    /**
     * 获取所有计价规则
     * @param page
     * @param limit
     * @param cityCode
     * @return
     */
    @GetMapping("/list")
    public Result getRulesList(@RequestParam int page, @RequestParam int limit, @RequestParam(required=false) String cityCode){
        return priceRuleService.getRulesList(page,limit,cityCode);
    }

    @ApiOperation("添加计价规则")
    @PostMapping("/add")
    public Result add(@RequestBody PriceRule priceRule){
        return priceRuleService.addRules(priceRule);
    }

    @ApiOperation("更新计价规则")
    @PostMapping("/edit")
    public Result edit(@RequestBody PriceRule priceRule){
        return priceRuleService.editRules(priceRule);
    }
}
